﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kevin.Framework.Data.OrmMapping
{
    /// <summary>
    /// 外键连接，用于查询
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
    public class ForeignFieldMappingAttribute : System.Attribute
    {
        public ForeignFieldMappingAttribute(string joinTableName, string myFieldName, string joinFieldName)
            : this(joinTableName, joinTableName, myFieldName, joinFieldName)
        {

        }

        public ForeignFieldMappingAttribute(string joinTableName, string aliseName, string myFieldName, string joinFieldName)
        {
            this.JoinTableName = joinTableName;
            this.AliseName = aliseName;
            this.MyFieldName = myFieldName;
            this.JoinFieldName = joinFieldName;
        }
        /// <summary>
        /// 连接表表名
        /// </summary>
        internal string JoinTableName
        {
            get;
            set;
        }
        /// <summary>
        /// 连接表别名
        /// </summary>
        internal string AliseName
        {
            get;
            set;
        }
        /// <summary>
        /// 连接表中显示的字段
        /// </summary>
        internal string FieldName
        {
            get;
            set;
        }
        /// <summary>
        /// 当前表中进行关联的字段
        /// </summary>
        internal string MyFieldName
        {
            get;
            set;
        }
        /// <summary>
        /// 连接表中关联的字段
        /// </summary>
        internal string JoinFieldName
        {
            get;
            set;
        }
    }
}
